package com.tjw.ec.upms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tjw.ec.common.core.util.PageUtils;
import com.tjw.ec.common.core.util.Query;
import com.tjw.ec.upms.api.dto.PermitVO;
import com.tjw.ec.upms.api.entity.PermitEntity;
import com.tjw.ec.upms.dao.PermitDao;
import com.tjw.ec.upms.service.PermitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 由tb_Module与tb_Action两表结合产生的系统基本权限表;
 *
 * @author T-junwen
 * @email t-junwen@foxmail.com
 * @date 2019-07-27 16:43:32
 */
@Service("permitService")
public class PermitServiceImpl extends ServiceImpl<PermitDao, PermitEntity> implements PermitService {

    @Autowired
    private PermitDao permitDao;

    @Override
    public PageUtils<PermitEntity> queryPage(Map<String, Object> params) {

        IPage<PermitEntity> page = new Query<PermitEntity>(params).getPage();

        QueryWrapper<PermitEntity> queryWrapper = new QueryWrapper<>();

        IPage<PermitEntity> data = baseMapper.selectPage(
                page,
                queryWrapper
        );

        return new PageUtils(data);
    }

    /**
     * @param userId
     * @Title: 根据用户编号获取用户权限
     * @Param: [userId]
     * @return: java.util.List<com.tjw.ec.upms.api.dto.PermitVO>
     * @Author: 田俊文
     * @Date: 2019/8/2 15:03
     * @Throws:
     */
    @Override
    public List<PermitVO> getPermitByUserId(String userId) {
        List<PermitVO> permits = permitDao.getPermitByUserId(userId);
        return permits;
    }

}
